package travel.region;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import swing.ButtonColumn;
import travel.Travel_Information_DAO;
import travel.Travel_Information_VO;

public class Region_service implements Region_Iservice {
	Region_DAO rd = new Region_DAO();
	
	@Override
	public DefaultTableModel regionInfo() {
		int dfm = 0;
		DefaultTableModel model = new DefaultTableModel(
				null,	new String[] { "여행지 이름", "추천 여행 기간", "최소 비용", "소개", "주의사항", "추천수","찜","" }
				) {
					Class[] columnTypes = new Class[] {
							String.class, String.class, String.class,
							String.class, String.class, String.class,
							Boolean.class, JButton.class
					};
					public Class getColumnClass(int columnIndex) {
						return columnTypes[columnIndex];
					}
					
						@Override
						public boolean isCellEditable(int row, int column) {
							if(column == 6|| column ==7){
							return super.isCellEditable(row, column);}
							else {
							return false; // 수정불가}
						}
						}
					
				};
			
				
		for(Travel_Information_VO tiv : rd.selectGiyic()){
			
//			tableD =new String[] { tiv.getTravel_duration(), tiv.getTravel_duration(),
//					tiv.getTravel_price(), tiv.getTravel_introdation(),
//					tiv.getTravel_notice(), tiv.getTravel_votes(),"true"
			model.addRow(new Object[] { tiv.getTravel_place(),  tiv.getTravel_duration(),
					tiv.getTravel_price(), tiv.getTravel_introdation(),
					tiv.getTravel_notice(), tiv.getTravel_votes(), false, null
				
			});
			
		}
		
		return model;	
	}// 테이블 뛰우기 로우로 집어넣기.

	@Override
	public void regionImage() {
		//테이블에 이미지 삽입시? 이거 물어보자.
	}

	@Override
	public void votesActtion() {
		Travel_Information_VO tiv = new Travel_Information_VO();
		int up = tiv.getTravel_votes();
		tiv.setTravel_votes(++up);
		System.out.println(tiv.getTravel_votes());
	}

}
